package com.stars.easyms.gateway.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>className: EasyMsGatewayProperties</p>
 * <p>description: EasyMs网关属性配置类</p>
 *
 * @author guoguifang
 * @version 1.6.1
 * @date 2020/8/27 6:02 下午
 */
@Data
@ConfigurationProperties(prefix = EasyMsGatewayProperties.GATEWAY_PREFIX)
public class EasyMsGatewayProperties {

    public static final String GATEWAY_PREFIX = "spring.cloud.gateway";

    private final Encrypt encrypt = new Encrypt();

    private final Log log = new Log();

    private boolean debugEnabled;

    private String servletPath;

    private final Map<String, String> service = new HashMap<>(8);

    /**
     * 加解密相关属性类
     */
    @Data
    public static class Encrypt {

        /**
         * 是否激活，默认激活
         */
        private boolean enabled = true;

        /**
         * 秘钥
         */
        private String secret;

        /**
         * 秘钥偏移量
         */
        private String iv;

        /**
         * 加密json中已加密的请求值对应的key值
         */
        private String requestKey;

        /**
         * 加密json中已加密的返回值对应的key值
         */
        private String responseKey;

        /**
         * 不做加解密的相关url
         */
        private String requestPermitUrl;

        /**
         * 不做加解密的相关url
         */
        private String responsePermitUrl;
    }

    @Data
    public static class Log {

        /**
         * 不需要记录日志的url
         */
        private String requestPermitUrl;

        /**
         * 不需要记录日志的url
         */
        private String responsePermitUrl;
    }

}
